import request from '@/utils/http'

// 新增
export const addGoodsAPI = (data) => {
  return request({
    url: 'admin/goods',
    method: 'POST',
    data
  });
};

// 分页查询
export const getGoodsPageAPI = (params) => {
  return request({
    url: 'admin/goods/page',
    method: 'GET',
    params
  });
};

// 删除
export const deleGoodsAPI = (ids) => {
  return request({
    url: 'admin/goods',
    method: 'DELETE',
    params: {
      ids
    }
  });
};

// 修改
export const editGoodsAPI = (data) => {
  return request({
    url: 'admin/goods',
    method: 'PUT',
    data
  });
};

//商品起售和停售
export const goodsByStatusAPI = (status, id) => {
  return request({
    url: `/admin/goods/status/${status}`,
    method: 'POST',
    params: {
      id
    }
  })
}

// 查询
export const getGoodsAPI = (id) => {
  return request({
    url: '/goods',
    method: 'GET',
    params: {
      id
    }
  })
}

// 规格
// 新增
export const addSpecAPI = (data) => {
  return request({
    url: 'admin/spec',
    method: 'POST',
    data
  });
};

// 分页查询
export const getSpecPageAPI = (params) => {
  return request({
    url: 'admin/spec/page',
    method: 'GET',
    params
  });
};

// 删除
export const deleSpecAPI = (ids) => {
  return request({
    url: 'admin/spec',
    method: 'DELETE',
    params: {
      ids
    }
  });
};

// 查询
export const getSpecAPI = () => {
  return request({
    url: 'admin/spec',
    method: 'GET',
  });
};

// 规格值
// 新增
export const addSpecValueAPI = (data) => {
  return request({
    url: 'admin/spec/value',
    method: 'POST',
    data
  });
};

// 分页查询
export const getSpecValuePageAPI = (params) => {
  return request({
    url: 'admin/spec/value/page',
    method: 'GET',
    params
  });
};

// 删除
export const deleSpecValueAPI = (ids) => {
  return request({
    url: 'admin/spec/value',
    method: 'DELETE',
    params: {
      ids
    }
  });
};

// 查询
export const getSpecValueAPI = () => {
  return request({
    url: 'admin/spec/value',
    method: 'GET',
  });
};

// sku
// 新增
export const addSkuAPI = (data) => {
  return request({
    url: 'admin/goods/sku',
    method: 'POST',
    data
  });
};

// 查询
export const getSkuAPI = (goodsId) => {
  return request({
    url: 'admin/goods/sku',
    method: 'GET',
    params: {
      goodsId
    }
  });
};

// 删除
export const deleSkuAPI = (id) => {
  return request({
    url: 'admin/goods/sku',
    method: 'DELETE',
    params: {
      id
    }
  });
};

// 修改
export const editSkuAPI = (data) => {
  return request({
    url: 'admin/goods/sku',
    method: 'PUT',
    data
  });
};